package com.qf.iostream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


public class OutputStreamTest {
	
	public static void main(String[] args) {
		
		String path = "D:\\Workspace\\Practice\\src\\writeTest01";
		
		outputStreamByTxtFile(path);
		
		
	}

	public static void outputStreamByTxtFile(String path) {
		
		File f = new File(path);

		try {
			FileOutputStream fileOut = new FileOutputStream(f,true);
			
			
			
			fileOut.write(98);
			fileOut.write(97);
			fileOut.write(96);
			fileOut.write(95);
			
			
			String str = "求知若饥，虚心若愚。";
			//数组数据写入输出流指定文件
			byte[] bs = str.getBytes();
			
			fileOut.write(bs);
			System.out.println("文件写入成功...");
		}
		catch(FileNotFoundException e1) {
			System.out.println("文件找不到！");
			
		}catch(IOException e2) {
			System.out.println("IO流异常！");
			
		}catch(Exception e) {
			System.out.println("未知异常！");
			
		}finally {
			
		}
		
		
		
	}
}
